/**
 * A JFrame used to display instructions and information about the developers of the
 * game when requested by the user
 * It is a JFrame that appears when a user requests information or instructions
 * 
 * @author Sarangan Balasubramaniam
 * @version 1.51
 */

package mainClasses;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class HelpAndAbout extends JFrame implements ActionListener{
	public static final int CHESS = 1;	//Chess
	public static final int QUEEN = 2;	//Eight Queens
	public static final int KNIGHT = 3; //Knights Tour
	public static final int US = 4;
	public static final int CHECKMATE1 = 5;
	public static final int CHECKMATE2 = 6;
	public static final int STALEMATE = 7;
	public int status = 0;
	JButton helpButton = new JButton();
	public HelpAndAbout()
	{
		this.setLayout(new GridLayout(1, 1));
		this.helpButton.addActionListener(this);
		this.add(helpButton);
	}
	
	/**
	 * Sets the help icon to the specific game
	 * @param game The kind of game being played
	 */
	public void setHelpIcon(int game)
	{
		if(game==HelpAndAbout.CHESS)
		{
			this.helpButton.setBackground(Color.BLACK);
			this.helpButton.setIcon(new ImageIcon("chess_help.PNG"));
		}else if(game==HelpAndAbout.QUEEN)
		{
			this.helpButton.setBackground(Color.BLACK);
			this.helpButton.setIcon(new ImageIcon("queen_help.PNG"));
		}else if(game==HelpAndAbout.KNIGHT)
		{
			this.helpButton.setBackground(Color.BLACK);
			this.helpButton.setIcon(new ImageIcon("knight_help.PNG"));
		}else if(game==HelpAndAbout.US)
		{
			this.helpButton.setBackground(Color.WHITE);
			this.helpButton.setIcon(new ImageIcon("about_us.PNG"));
			this.status = 1;
		}else if(game==HelpAndAbout.CHECKMATE1)
		{
			this.helpButton.setBackground(Color.WHITE);
			this.helpButton.setIcon(new ImageIcon("check_mate1.PNG"));
		}else if(game==HelpAndAbout.CHECKMATE2)
		{
			this.helpButton.setBackground(Color.WHITE);
			this.helpButton.setIcon(new ImageIcon("check_mate2.PNG"));
		}else if(game==HelpAndAbout.STALEMATE)
		{
			this.helpButton.setBackground(Color.WHITE);
			this.helpButton.setIcon(new ImageIcon("stal_mate.PNG"));
		}
	}
	
	
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==this.helpButton)
		{
			if(this.status==1)
			{
				this.helpButton.setBackground(Color.WHITE);
				this.helpButton.setIcon(new ImageIcon("about_game.PNG"));
				this.status = 0;
			}else if(this.status==0)
			{
				setVisible(false);
			}
		}
		
	}

}
